package behavior.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author dali
 * @date 2021-07-26 16:21
 * @Description 抽象主题
 */

public abstract class Subject {
    //创建观察者集合
    protected List<Observer> list;

    public Subject() {
        list = new ArrayList<>();
    }

    public boolean addObserver(Observer o){
        return list.add(o);
    }

    public boolean removeObserver(Observer o){
        return list.remove(o);
    }

    public abstract void notifyObserver();
}
